package com.gg.admin.user.contorller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.admin.user.service.AdminUserService;
import com.gg.beanhelper.BeanHelper;
import com.gg.entity.User;

import helpers.baseservlet.BaseServlet;

@WebServlet("/admin/AdminAddUserServlet")
public class AdminAddUserServlet extends BaseServlet {
	@Autowired
	private AdminUserService adminUserService;

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		User user = BeanHelper.getBean(request.getParameterMap(), User.class);
		adminUserService.addUser(user);
		request.getSession().setAttribute("users", adminUserService.ShowAllUsers());
		response.sendRedirect("/fruits/BSindex1.jsp");
	}
}
